/*
失败的纯数组实验，用python这样的不限制大小的语言应该能解决。
time:20201018 22:20 PM
key:1.字符串转long long有现成的函数stoll()。其次题目id最大值不超过long
 long。
	2.C++的动态数组最大空间不满足，所以应该要在主函数之外动态开辟空间。
*/
#include <math.h>
#include <iostream>
#include<string>
#include <string>
#include<stdio.h>
using namespace std;
const long long sushu = 999997;
long long str_to_long(string s)//id转哈希数值，先不考虑id末位为x的id。
{
	
	return (stoll(s)%sushu);
}
void save()
{
	1;
}
void read()
{

		
}

int main()
{
	long long k, n, count;
	cin >> n;//保存记录数
	cin >> k;//最低里程
	//以字符串的形式读入身份证
	int i;
	string* s1 = new string[n];
	long long* mile = new long long[n];
	long long max_long_id=sushu;

	for (i = 0; i < n; i++)
	{
		cin >> s1[i];

		cin >> mile[i];
	}
	//建立哈希数组,因为从0开始的数组，最大个数为下标不会被读到。所以new long long[max_long_id+1];
	unsigned long long* id_array = new unsigned long long[max_long_id];
	for (i = 0; i <= max_long_id; i++)
	{
		id_array[i] = 0;
	}
	for (i = 0; i < n; i++)
	{
		if (mile[i] < k)
		{
			mile[i] = k;
		}

		id_array[str_to_long(s1[i])] += mile[i];
		//cout << str_to_long(s1[i]) << endl;
	}
	//尝试读取
	cin >> n;
	string read_id;
	for (i = 0; i < n; i++)
	{
		cin >> read_id;
		if (id_array[str_to_long(read_id)] != 0)
		{
			
			cout << id_array[str_to_long(read_id)] ;
		}
		else
		{
			cout << "No Info";
		}
		if (i != n - 1)
		{
			cout<<"\n";
		}
	}
}

	



